package com.yzh.openai.config;


import com.yzh.zhipu.session.ChatGlmSession;
import com.yzh.zhipu.session.ChatGlmSessionFactory;
import com.yzh.zhipu.session.impl.ChatGlmSessionFactoryImpl;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(ChatGLMConfigProperties.class)
public class ChatGLMConfig {
    
    @Bean
    public ChatGlmSession ChatGlmSession(ChatGLMConfigProperties properties) {
        com.yzh.zhipu.session.Configuration configuration = new com.yzh.zhipu.session.Configuration();
        configuration.setApiHost(properties.getApiHost());
        configuration.splitSecretKey(properties.getApiKey());

        ChatGlmSessionFactory factory = new ChatGlmSessionFactoryImpl(configuration);
        return factory.openSession();
    }
}
